﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeGenerator.CSharp
{
    /// <summary>
    /// Identifies some metadata about a code unit that is accessible through the CLR at runtime.
    /// </summary>
    public class Attribute
    {
        public string Text { get; set; }

        public override string ToString()
        {
            return "[" + this.Text + "]";
        }
    }

    /// <summary>
    /// Defines a collectino of attributes.
    /// </summary>
    public class AttributeCollection : List<Attribute>
    {

        public CodeGenerator.CSharp.Attribute Add(string text)
        {
            CodeGenerator.CSharp.Attribute ThisAttribute = new CodeGenerator.CSharp.Attribute() { Text = text };
            this.Add(ThisAttribute);
            return ThisAttribute;
        }

        public override string ToString() { return this.ToString(0); }

        public string ToString(int indentationLevel)
        {
            CodeBuilder Code = new CodeBuilder();
            string Padding = new string(char.Parse(" "), indentationLevel * Settings.CharactersPerTab);

            foreach (Attribute ThisAttribute in this)
                Code.Add(Padding + ThisAttribute);

            return Code.ToString();
        }
    
    }
}
